/*
 * Created on 11 juin 2005
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package mygui;

import javax.swing.*;
import java.util.*;
import kernel.Simulator;
import objects.MobileStation;

/**
 * @author drosenda
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class RoutingFrame extends JFrame {

	Simulator sim;
	
	//Vector labels;
	
	JTabbedPane onglets;
	
	int a;
		
	/**
	 * @param title
	 */
	public RoutingFrame(Simulator s) {
		super("RoutingFrame");
		
		sim = s;
		
		//labels = new Vector();
		onglets = new JTabbedPane();
		
		this.getContentPane().add(onglets);
		
		this.setBounds(0,MonIHM.HEIGHT,330,240);
		update();
		this.setVisible(false);
		a=0;	
	}
	
	public void update(){
		//System.out.println("update RoutingFrame" + a++);
		//labels.clear();
		String selecStr = "";
		try{
			selecStr = onglets.getTitleAt(onglets.getSelectedIndex());
		}
		catch(Exception e){}
		onglets.removeAll();
		Vector stations = sim.getMobileStation();
		int selecInt = 0;
		for (int i=0; i<stations.size(); i++){
			MobileStation ms = ((MobileStation) (stations.get(i)));
			if (ms.getName().equals(selecStr))
				selecInt = i;
			onglets.addTab(ms.getName(),new JTextArea(ms.getRouter().routingTableToString()));
		}
		//System.out.println("selecInt : " + selecInt);
		try{
			onglets.setSelectedIndex(selecInt);
		}catch (Exception e){}
		//this.repaint();
	}

	public static void main(String[] args) {
	}
}
